package com.example.service.impl;

import com.example.dao.UserDao;
import com.example.dao.impl.UserDaoImpl;
import com.example.model.User;
import org.springframework.stereotype.Service;
import com.example.service.UserService;

@Service
public class UserServiceImpl implements UserService {

    private UserDao userDao = new UserDaoImpl();
    @Override
    public boolean registr(User user) {
        if (null == userDao.findUserByUsername(user.getUsername())) {
            // 用户不存在 , 可以注册
            userDao.addUser(user);
            return true;
        } else {
            // 用户存在
            return false;
        }

    }

    @Override
    public User login(String username, String password) {
        User user = userDao.findUserByUnameAndPass(username,password);
        return user;
    }
}
